package com.wego.converter;

import com.wego.bean.BaseConverter;
import com.wego.bean.ExcelConverter;
import com.wego.domain.UserInfo;
import com.wego.domain.details.UserDetails;
import com.wego.domain.dto.UserDTO;
import com.wego.domain.entity.User;
import com.wego.domain.excel.UserExcel;
import com.wego.domain.vo.UserVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.util.List;

@Mapper(componentModel = "spring")
public interface UserConverter extends BaseConverter<User, UserVO, UserDetails,UserDTO>, ExcelConverter<User, UserExcel> {
    @Mapping(target = "token", ignore = true)
    UserInfo user2userInfo(User user);

    User userDTO2user(UserDTO userDTO);

    @Mapping(target = "gender", expression = "java(com.wego.domain.enums.UserGender.getTextByCode(user.getGender()))")
    @Mapping(target = "state", expression = "java(com.wego.domain.enums.UserState.getTextByCode(user.getState()))")
    UserDetails user2userDetails(User user);

    UserVO user2userVO(User user);

    @Mapping(target = "gender", expression = "java(com.wego.domain.enums.UserGender.getTextByCode(user.getGender()))")
    @Mapping(target = "state", expression = "java(com.wego.domain.enums.UserState.getTextByCode(user.getState()))")
    UserExcel user2userExcel(User user);

    List<UserExcel> userList2userExcelList(List<User> userList);

    @Mapping(target = "gender", expression = "java(com.wego.domain.enums.UserGender.getCodeByText(userExcel.getGender()))")
    @Mapping(target = "state", expression = "java(com.wego.domain.enums.UserState.getCodeByText(userExcel.getState()))")
    User userExcel2user(UserExcel userExcel);

    List<User> userExcelList2userList(List<UserExcel> userExcelList);

}
